<!DOCTYPE html PUBLIC "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<!-- saved from url=(0049)http://www.zj.gov.cn/pertool_subsite/login_sm.jsp -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache, must-revalidate">
<meta http-equiv="expires" content="0">
<title>登录</title>
<link href="favicon.ico" type="image/x-icon" rel=icon>
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
<link rel="stylesheet" type="text/css" href="resources/css/login.css" />
<link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all-access.css">
<!-- <script type="text/javascript" src="extjs/ext-all.js"></script> -->
<!-- for testing purpose -->
<script type='text/javascript' src='extjs/ext-all-debug.js'></script>
<script type="text/javascript" src="test.js"></script>
<!-- /for testing purpose -->
<script type="text/javascript" src="extjs/locale/languageSwitch.js"></script>
<!-- <script type="text/javascript" src="extjs/locale/cfWeb_lang_cn.js"></script>
<script type="text/javascript" src="extjs/locale/cfWeb_lang_en.js"></script>   -->
<script type="text/javascript">
Ext.Ajax.timeout =300000;
function slogin() {
	var psw = Ext.get("psd").getValue();
	var name = Ext.get("username").getValue();
	var target = Ext.get("cloudTarget").getValue();
/* 	if(psw=='123456'&&name=="admin"){
		Ext.MessageBox.alert('登录成功','现在进行重定向，请稍候...');
		window.location="./index.html";
	}else{
		Ext.get("error").dom.style.display="";
		window.location="./login.html"
	}; */
	var button  = Ext.get("login");
	if(!button.hasCls('on')){
		button.dom.innerHTML = '登录中...';
		button.addCls('on');
		Ext.Ajax.request({
	     	url:'rest/login/checkLogin',
	     	method:'GET',
	     	params:{
	     		loginName : name,
	     		password : psw,
	     		target:target
	     	},
	     	success:function(response){
	     		console.log(response.responseText);
	     		var obj= Ext.decode(response.responseText);
				if(obj.data.logined==false){
					Ext.get("error").dom.style.display="";
	     			button.removeCls('on');
	     			button.dom.innerHTML = '登录';
				}else{
	     		//	Ext.MessageBox.alert('登录成功', '现在进行重定向，请稍后...');
	     			window.location = './index.html';
	     		}

	     	},
	     	failure:function(response){
	     		var obj= Ext.JSON.decode(response.responseText);
	     		if(obj.data!=null&&obj.data.errorCode==401){
	     			Ext.get("error").dom.style.display="";
	     			button.removeCls('on');
	     			button.dom.innerHTML = '登录';
	     		}else if(obj.data!=null&&obj.data.source==1){
					Ext.MessageBox.alert(cfWebLang.ErrorSource.cloudfoundry,obj.data.message,function(btn){
						if(btn=='ok'){
							window.location = "./login.html";
						}
					});
				}else if(obj.data!=null&&obj.data.source!=1){
					Ext.MessageBox.alert(cfWebLang.ErrorSource.app,cfWebLang.Error.SystemError,function(btn){
						if(btn=='ok'){
							window.location = "./login.html";
						}
					});
				}else{
					Ext.MessageBox.alert(cfWebLang.ErrorSource.app,cfWebLang.Error.SystemError,function(btn){
						if(btn=='ok'){
							window.location = "./login.html";
						}
					});
				}
	     	}
	     });
	}
  }
Ext.onReady(function(){
		Ext.Ajax.request({
				url:'rest/login/getAllCloud',
				method:'GET',
				success:function(response){
					var obj = Ext.decode(response.responseText);
					for(var i=0;i<obj.data.length;i++){
	                    Ext.get('cloudTarget').dom.innerHTML = '<option value="'+obj.data[i]+'">'+obj.data[i]+'</option>';
					}

				}
		});

	if(Ext.get("psd").getValue().length!=0){
		Ext.get("psd").next().hide();
	}

	if(Ext.get("username").getValue().length!=0){
		Ext.get("username").next().hide();
	}

	Ext.get("psd").on("keyup",function(e, t, eOpts){
		if(e.button == 12){
			slogin();
		}
		if(this.getValue().length == 0){
			this.next().show();
		}
		else{
			this.next().hide();
			Ext.get("error").dom.style.display="none";
		}
	});

	Ext.get("username").on("keyup",function( ){

		if(this.getValue().length == 0){
			this.next().show();
		}
		else{
			this.next().hide();
			Ext.get("error").dom.style.display="none";
		}
	});
	Ext.get("login").on("click",function(){
		slogin();
	});
});
</script>
</head>
<body >
<div class="container">
  <div class="head">
      <div class="logo"></div>
      <p class="title">宁波政务云计算中心</p>
  </div>
  <div class="content">
      <div class="login_wrap">
          <h3 class="login_title">用户登录</h3>
          <div class="error" id="error" style="display:none;">您输入的用户名或密码不正确！</div>
          <div class="login_content">
          	<input type="text" id="username"/>
            <label class="tip">请输入用户名</label>
            <input type="password" id="psd" />
            <label class="tip">请输入密码</label>
            <select id="cloudTarget">
               <option>请选择云</option>
            </select>
            <div class="login_action">
              <div  id="login">登录</div>
            </div>
          </div>
      </div>
      <div>

      </div>
      <div style="clear:both"></div>
  </div>
</div>

</body>
</html>
